//
//  WENRootController.m
//  仿百思不得姐
//
//  Created by yulf213 on 2018/2/6.
//  Copyright © 2018年 wen. All rights reserved.@""
//

#import "WENRootController.h"
#import "UIImage+WENExtension.h"
#import "WENTabBar.h"
#import "WENNewViewController.h"
#import "WENFriendTrendsViewController.h"
#import "WENMeViewController.h"
#import "WENEssenceViewController.h"
@interface WENRootController ()

@end

@implementation WENRootController

- (void)viewDidLoad {
    [super viewDidLoad];
    //
    [self addChildVCs];
    
    WENTabBar *tabBar = [[WENTabBar alloc] init];
    [self setValue:tabBar forKey:@"tabBar"];
    
//    皮肤设置
    UITabBarItem * itemAppearance = [UITabBarItem appearance];
    NSDictionary *dict = @{
                           NSForegroundColorAttributeName:[UIColor darkGrayColor]
                           };
    [itemAppearance setTitleTextAttributes:dict forState:UIControlStateSelected];

}


//添加子控制器
- (void)addChildVCs {
    //精华
    [self setUpChildViewController:[[WENEssenceViewController alloc] init] title:@"精华" imageNamed:@"tabBar_essence_icon"];
    
    //精华
    [self setUpChildViewController:[[WENNewViewController alloc] init] title:@"新帖" imageNamed:@"tabBar_new_icon"];
    
    //精华
    [self setUpChildViewController:[[WENFriendTrendsViewController alloc] init] title:@"关注" imageNamed:@"tabBar_friendTrends_icon"];
    
    //精华
    [self setUpChildViewController:[[WENMeViewController alloc] init] title:@"我" imageNamed:@"tabBar_me_icon"];
    
    
}

//创建子控制器的方法
- (void)setUpChildViewController:(UIViewController *)vc title:(NSString *)title imageNamed:(NSString *)imageName  {

    UINavigationController *naVc = [[UINavigationController alloc] initWithRootViewController:vc];
    
    vc.tabBarItem.title = title;

//修改tabBarItem.title选中后的颜色
//    NSDictionary *dict = @{
//                           NSForegroundColorAttributeName:[UIColor darkGrayColor]
//                           };
//    [vc.tabBarItem setTitleTextAttributes:dict forState:UIControlStateSelected];
    
    vc.tabBarItem.image = [UIImage imageNamed:imageName];
    NSString *selectImageName = [imageName stringByAppendingString:@"_click"];
    vc.tabBarItem.selectedImage = [UIImage wen_originarImageNamed:selectImageName];
    [self addChildViewController:naVc];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
